package com.fish.yssb.ui.page.activity.setPara;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsoluteLayout;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fish.yssb.R;
import com.fish.yssb.ui.page.activity.base.BaseActivity;
import com.fish.yssb.ui.page.util.PrefeneceUtil;
import com.fish.yssb.ui.page.util.TopToastUtil;
import com.fish.yssb.ui.page.widget.CustomDialog;
import com.jaeger.library.StatusBarUtil;


/**
 * A login screen that offers login via email/password.
 */
public class SetParaThreeActivity extends BaseActivity implements OnClickListener {
    private static final String TAG = SetParaListActivity.class.getSimpleName();


    EditText et_deveveid;
    EditText et_log_max,et_out_time;
    EditText et_ip;
    LinearLayout tv_back;
    TextView  tv_save,et_cs,et_tcp,tv_set;
    private RelativeLayout ll_para_2, ll_para_3;
    private CustomDialog choosePicDialog;

    private int sevice_type,net_type;

    public static void start(Context context) {
        Intent intent = new Intent(context, SetParaThreeActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sevice_type = -1;
        net_type = -1;

        StatusBarUtil.setTransparent(this);
        StatusBarUtil.setDarkMode(this);
        setContentView(R.layout.activity_setpara_three);
        et_log_max = findViewById(R.id.et_log_max);
        et_out_time = findViewById(R.id.et_out_time);
        initview();
        initData();
    }

    private void initData()
    {
        et_log_max.setText(PrefeneceUtil.getData("para3_et_log_max","30",false));
        et_out_time.setText(PrefeneceUtil.getData("para3_et_out_time","100",false));
    }



    //初始化视图
    @SuppressLint("WrongViewCast")
    private void initview() {
        //登录层、下拉层、其它登录方式层

        tv_back = findViewById(R.id.tv_back);
        tv_save = findViewById(R.id.tv_save);
        et_ip = findViewById(R.id.et_ip);
        ll_para_2 = findViewById(R.id.ll_para_2);
        ll_para_3 = findViewById(R.id.ll_para_3);
        et_tcp = findViewById(R.id.et_tcp);
        et_cs = findViewById(R.id.et_cs);
        tv_set = findViewById(R.id.tv_set);
        tv_set.setOnClickListener(this);
        tv_back.setOnClickListener(this);


    }

    private LinearLayout lyDlg;
    private TextView btn1, btn2, btnCancel;
    private Window window;

    @Override
    public void onClick(View view) {

        switch (view.getId()) {



            case R.id.ll_para_2:


                break;

            case R.id.ll_para_3:



                break;
            case R.id.tv_back:
                finish();
                break;
            case R.id.tv_save:

                break;
            case R.id.tv_set:
                hideSoftKeyboard(this);
                PrefeneceUtil.setData("para3_et_log_max",et_log_max.getText().toString(),false);
                PrefeneceUtil.setData("para3_et_out_time",et_out_time.getText().toString(),false);
                TopToastUtil.getInstance(this,R.layout.showdialog).showShortToast("保存成功");
                startAD();
                break;
            default:
                break;
        }


    }
    public static void hideSoftKeyboard(Activity activity) {
        View view = activity.getCurrentFocus();
        if (view != null) {
            InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

}

